/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.icatportal.client.mvc;

import com.extjs.gxt.ui.client.Registry;
import com.extjs.gxt.ui.client.Style.LayoutRegion;
import com.extjs.gxt.ui.client.mvc.AppEvent;
import com.extjs.gxt.ui.client.mvc.Controller;
import com.extjs.gxt.ui.client.mvc.View;
import com.extjs.gxt.ui.client.widget.LayoutContainer;
import com.extjs.gxt.ui.client.widget.layout.BorderLayout;
import com.extjs.gxt.ui.client.widget.layout.BorderLayoutData;
import org.icatportal.client.AppEvents;
import org.icatportal.client.widget.PreferencePanel;

/**
 *
 * @author ll56
 */
public class PreferenceView extends View {

    private LayoutContainer container;
    private PreferencePanel panel;

    public PreferenceView(Controller controller) {
        super(controller);
    }

    @Override
    protected void initialize() {
        container = new LayoutContainer();

        BorderLayout layout = new BorderLayout();
        layout.setEnableState(false);
        container.setLayout(layout);
        panel = new PreferencePanel();

        container.add(panel, new BorderLayoutData(LayoutRegion.CENTER));

    }

    @Override
    protected void handleEvent(AppEvent event) {
        if (event.type == AppEvents.NavPreference) {
            LayoutContainer wrapper = (LayoutContainer) Registry.get("center");
            wrapper.removeAll();
            wrapper.add(panel);
            wrapper.layout();
        }
    }
}

